package com.logistics.system.consumer.listener;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FanoutConfig {

//    声明fanout交换机,名字叫做longxf.fanout
    @Bean
    public FanoutExchange fanoutExchange() {
        return new FanoutExchange("basic.queue");
    }

    //声明第一个队列
    @Bean
    public Queue fanoutQueue1() {
        return new Queue("basic.queue1");
    }
//
    //将队列1绑定到交换上
    @Bean
    public Binding bindingQueue1(Queue fanoutQueue1, FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(fanoutQueue1).to(fanoutExchange);
    }

}